package me.firstapp.module.shop;

import java.util.Date;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.UniqueConstraint;

import me.firstapp.module.base.CommonEntity;
import me.firstapp.module.bbs.Member;

@Entity
@Table(name = "PRODUCT_COMMENT", uniqueConstraints = {
		@UniqueConstraint(columnNames = { "FROM_MEMBER_ID", "ORDER_NO", "PRODUCT_ID" }) })
public class ProductComment extends CommonEntity {

	private static final long serialVersionUID = -6441034486613747303L;

	// 订单号
	@Column(name = "ORDER_NO", length = 50, nullable = false)
	private String orderNo;

	// 关联的商品
	@Column(name = "PRODUCT_ID", nullable = false)
	private Long productId;

	// 评论的内容
	@Column(name = "CONTENT", columnDefinition = "text", nullable = false)
	private String content;

	// 添加评论的用户
	@ManyToOne(fetch = FetchType.LAZY)
	@JoinColumn(name = "FROM_MEMBER_ID", referencedColumnName = "ID", nullable = false)
	private Member fromMember;

	// 创建时间
	@Column(name = "CREATE_TIME", nullable = false)
	private Date createTime;

	public Long getProductId() {
		return productId;
	}

	public void setProductId(Long productId) {
		this.productId = productId;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public Member getFromMember() {
		return fromMember;
	}

	public void setFromMember(Member fromMember) {
		this.fromMember = fromMember;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Date createTime) {
		this.createTime = createTime;
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

}
